package com.dq;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

/**
 * @ClassName ServletHandler
 * @Description TODO
 * @Author DuX1aoQiang
 * @Date 2023/5/28 20:01
 * @Version 1.0
 */
public class ServletHandler extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println(req.getMethod());
        resp.addHeader("Content-Length","11");
        resp.addHeader("Content-Type","text/plain;charset=utf-8");
        resp.getOutputStream().write("hello world".getBytes());  //这会是null getOutputStream没有值
    }
}
